<template>
  <div class="List">
    <el-container>
      <el-header>
        <div style="border-bottom: 1px solid black">用户列表-密码重置-冻结</div>
      </el-header>
      <el-main>
		  <!--  -->
		  <el-table
		    :data="users"
		    border
		    style="width: 100%"
		    row-key="type"
		    :lazy="true"
		    :tree-props="{ children: 'child' }"
		  >
		    <el-table-column prop="account" label="账号唯一" width="200">
		    </el-table-column>
		    <el-table-column prop="closed" label="激活或冻结" width="200">
				<template #default="scope">
					<el-button @click="dj(scope.row.id,scope.row.closed)">{{scope.row.closed == 0 ? '冻结':'激活'}}</el-button>
				</template>
		    </el-table-column>
		    <el-table-column prop="id" label="系统编号" width="200">
		    </el-table-column>
			<el-table-column prop="img" label="人头图片编号" width="200">
			</el-table-column>
			<el-table-column prop="nickname" label="用户名称,网名" width="200">
			</el-table-column>
			<el-table-column prop="phone" label="电话" width="200">
			</el-table-column>
			<el-table-column prop="role" label="角色编号" width="200">
			</el-table-column>
		  </el-table>
		  <!--  -->
	  </el-main>
    </el-container>
  </div>
</template>

<script>
export default {
  name: "List",
  data(){
	  return{
		users:[],
	  }
  },
  created() {
  	this.chushi();
  },
  methods:{
	  dj(id,s){
		  console.log(s);
		  console.log(id);
		  if(s==0){
			  // 冻结
			  this.axios
			  .post("/api/adm/user/close/"+id)
			  .then((res) => {
			  			  console.log(res);
			  }).catch((error)=>{
			  			  console.log(error);
			  })
			  this.chushi();
		  }else if(s==1){
			  // 解冻
			  this.axios
			  .post("/api/adm/user/resetPwd/"+id)
			  .then((res) => {
			  	console.log(res);
				this.chushi();
			  }).catch((error)=>{
			  	console.log(error);
			  })
		  }
	  },
	  chushi(){
		  this.axios
		  .get("/api/adm/user/findAll").then((res)=>{
		  	console.log(res.data.data);
		  	this.users = res.data.data.users;
		  }).catch((error)=>{
		  	console.log(error);
		  })
	  }
  }
};
</script>

<style scoped></style>
